<template>
<div>
  <FormDetailNoImg :dataModel="[dataModel.detailShowInfo]" />
  <FormDetailNoImg :dataModel="[dataModel.checkDeviceShowInfo]" />
  <FormDetailNoImg :dataModel="[dataModel.checkOperateShowInfo]" />
  <FormDetailNoImg :dataModel="[dataModel.checkItemsShowInfo]" />
</div>
</template>

<script>
import FormDetailNoImg from '@/components/formEdit/formDetailNoImg'
export default {
components:{FormDetailNoImg},
props:["dataModel"],
data(){
   const {fullPath}=this.$route
  return {
     paginationInfo1: {
        sizeChange: (e) => {
          console.log(e);
        },
        currentChange: (e) => {
        
          this.$store.dispatch("supply/requestRelateList", {
            current: e,
              productId:localStorage.getItem(fullPath+"/productId")
          }).then(res=>{
            this.dataModel.checkDeviceShowInfo.tableData=res.data.records
          }).catch(err=>{

          })
        },
        current: 1,
        total: 10 ,
      },
      paginationInfo2: {
        sizeChange: (e) => {
          console.log(e);
        },
        currentChange: (e) => {
        
          this.$store.dispatch("supply/requestInstockList", {
            current: e,
              productId:localStorage.getItem(fullPath+"/productId")
          }).then(res=>{
 this.dataModel.checkOperateShowInfo.tableData=res.data.records
          }).catch(err=>{
            
          })
        },
        current: 1,
        total: 10 ,
      },
      paginationInfo3: {
        sizeChange: (e) => {
          console.log(e);
        },
        currentChange: (e) => {
        
          this.$store.dispatch("supply/requestOutstockList", {
            current: e,
            productId:localStorage.getItem(fullPath+"/productId")
          }).then(res=>{
 this.dataModel.checkItemsShowInfo.tableData=res.data.records
          }).catch(err=>{
            
          })
        },
        current: 1,
        total: 10 ,
      },
  }
},
created(){
    console.log(this.dataModel)
    //拉取相关数据详情列表
    const {fullPath}=this.$route
    const args={}
    args.id=localStorage.getItem(fullPath)
    args.productId=localStorage.getItem(fullPath+"/productId")
    this.$store.dispatch("supply/requestDetailList",args).then(res=>{
                this.dataModel.detailShowInfo.content.forEach(e=>{
            e.value=(this.$store.state.supply.supplyDetaillist.detailInfo)[e.name]
                })
                //关联设备列表
        this.dataModel.checkDeviceShowInfo.tableData=this.$store.state.supply.supplyDetaillist.deviceList.records
        this.dataModel.checkDeviceShowInfo.paginationInfo=this.paginationInfo1
        this.dataModel.checkDeviceShowInfo.paginationInfo.total=this.$store.state.supply.supplyDetaillist.deviceList.total
        //入库记录
         this.dataModel.checkOperateShowInfo.tableData=this.$store.state.supply.supplyDetaillist.instock.records
       this.dataModel.checkOperateShowInfo.paginationInfo=this.paginationInfo2
        this.dataModel.checkOperateShowInfo.paginationInfo.total=this.$store.state.supply.supplyDetaillist.instock.total
       //出库记录
         this.dataModel.checkItemsShowInfo.tableData=this.$store.state.supply.supplyDetaillist.outstock.records
         this.dataModel.checkItemsShowInfo.paginationInfo=this.paginationInfo3
         this.dataModel.checkItemsShowInfo.paginationInfo.total=this.$store.state.supply.supplyDetaillist.outstock.total
    }
      
    )
},
// watch:{
//   "this.$store.state.supply":{
//       handler(){
//        console.log(this.dataModel.detailShowInfo)
//        //组装备件基本信息
       
//        if(this.$store.state.supply.supplyDetaillist.detailInfo){
//           this.dataModel.detailShowInfo.content.forEach(e=>{
//            e.value=(this.$store.state.supply.supplyDetaillist.detailInfo)[e.name]
//        })
//        //关联设备列表
//        this.dataModel.checkDeviceShowInfo.tableData=this.$store.state.supply.supplyDetaillist.deviceList.records
//        //将最新的数据组装赋给试图数据
       
//       }
//        },
      
//       immediate:true,
//       deep:true
//   }
// },
//  computed: {
//     ...mapState(["supply","app"]),
//   },
}
</script> 